	import request from "@/utils/request.js";



	/**未登录get 请求*/
	let noAuthget = (url, data) => {
		return request.get(url, data, {
			noAuth: true
		});
	}
	/**未登录post 请求*/
	let noAuthpost = (url, data) => {
		return request.post(url, data, {
			noAuth: true
		});
	}

	/**get 请求*/
	let get = (url, data) => {
		return request.get(url, data);
	}
	/** post 请求*/
	let post = (url, data) => {
		return request.post(url, data);
	}

	/**上传图片*/
	let Fileupload = (url) => {
		url = Array.isArray(url) ? url[0] : url;
		let data = {
			returnPath: 'true'
		};
		let header = {
			"XX-Device-Type": 'wxapp',
			"XX-Token": uni.getStorageSync('token') || ''
		}
		return new Promise((resolve, reject) => {
			uni.uploadFile({
				url: request.HTTP_REQUEST_URL_IMG,
				header: header,
				type: 'POST',
				filePath: url,
				name: 'file',
				formData: data,
				success: (res) => {
					console.log('上传成功', res);
					let datas = JSON.parse(res.data);
					resolve(datas)
				},
				fail(err) {
					console.log('上传失败', err);
					reject(err)
				}
			});
		})
	}

	let api = {
		noAuthget: noAuthget,
		noAuthpost: noAuthpost,
		get: get,
		post: post,
		upload: Fileupload,

		/**案例 */
		OOO: {
			/**说明 */
			XXX: (data) => {
				return post('api/OOO/XXX', data)
			},
		},

	}

	export default api